<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 定义一个字符串
        var str = "i love javascript very much";
        // 分割字符串,转为数组
        var arr = str.split(" ");
        // 给每个数据的首字符大写
        for (var i = 0 ; i < arr.length ; i++) {
            arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].slice(1);
        }
        // 转回字符串
        str = arr.join(" ");
        console.log(str);
    </script>
</head>
<body>
    
</body>
</html>